package fastwave.cloud.demo.fastwave.biz.subscriber.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>Title: BlogConfig</p>
 * <p>Description: </p>
 *
 * @author: dwLiu
 * @date: 2020/4/7 16:58
 */
@Configuration
public class BlogConfig {

    @Bean
    TopicExchange BlogExchange(){
        return new TopicExchange("BlogExchange");
    }

    /**
     * 队列
     * @return
     */
    @Bean
    Queue BlogJavaQueue(){
        //true：持久化
        return new Queue("BlogJavaQueue",true);
    }

    /**
     * 队列
     * @return
     */
    @Bean
    Queue BlogDotNetQueue(){
        //true：持久化
        return new Queue("BlogDotNetQueue");
    }

    /**
     * 队列
     * @return
     */
    @Bean
    Queue BlogAllQueue(){
        //true：持久化
        return new Queue("BlogAllQueue",true);
    }

    /**
     * 交换机和队列绑定
     * @return
     */
    @Bean
    Binding BindToJavaQueue(){
        return BindingBuilder.bind(BlogJavaQueue()).to(BlogExchange()).with("blog.java");
    }

    /**
     * 交换机和队列绑定
     * @return
     */
    @Bean
    Binding BindToDotNetQueue(){
        return BindingBuilder.bind(BlogDotNetQueue()).to(BlogExchange()).with("blog.dotNet");
    }

    /**
     * 交换机和队列绑定
     * @return
     */
    @Bean
    Binding BindToAllQueue(){
        return BindingBuilder.bind(BlogAllQueue()).to(BlogExchange()).with("blog.#");
    }
}
